<template>
  <div class="writeform">
    <form class="form-cont">
      <div class="form-group">
        <label class="pb10">建议描述：</label>
        <textarea name="title" rows="3" class="form-control" placeholder="请输入文字"></textarea>
      </div>
      <div class="form-group formline">
        <label>截图：</label>
      </div>
      <div class="form-group uploadimage">
        <a class="companypic" id="chooseImages" @click="getSig()">
          <i class="ion ion-android-add fontcompany"></i>
          <span class="bluecolor block">点击上传照片</span>
        </a>
      </div>
      <div class="savebtn">
        <button type="button" class="">保存</button>
        <button type="button" class="">保存并提交</button>
      </div>
    </form>
  </div>
</template>

<script type="text/javascript">
  import wx from 'weixin-js-sdk'

  import jssdk from '../../assets/js/jssdk/wxJSSDK'

  // import checkApi from '../../assets/js/jssdk/lib/checkJsApi'

  export default {
    data() {
      return {}
    },
    mounted() {
      jssdk.init();
      // alert(window.location.href)
    },
    methods: {
      getSig() {
        var chooseImageID = "";
        var uploadImageID = "";
        var imageId = document.getElementById('chooseImages');
        console.log(imageId);
        debugger;
        jssdk.imageApi({
          chooseImage: {
            count: 6, // 默认9
            sizeType: ['original', 'compressed'],       // 可以指定是原图还是压缩图，默认二者都有
            sourceType: ['album', 'camera'],            // 可以指定来源是相册还是相机，默认二者都有
            success: function (res) {
              chooseImageID = res.localIds[0];
              imageId.innerHTML = "<img style='width:100%' src='" + chooseImageID + "'>";
              console.log("gongsi------------" + chooseImageID);
              jssdk.imageApi({
                uploadImage: {
                  localId: chooseImageID.toString(),
                  success: function (res) {
                    uploadImageID = res.serverId;
                    console.log("gongsi------------" + uploadImageID);
                  }
                }
              })
            }
          }
        })
      }
    }
  }
</script>
